00001
00005 class Audio
00006 {
00007 private:
00008
00013 ALuint sound_id;
00014
00019 ALuint sound_crash_id;
00020
00025 int play_flag;
00026
00031 ALuint boom[2];
00032
00037 ALCdevice *dev;
00038
00043 ALvoid* data;
00044 ALCcontext *context_id;
00045
00050 ALuint moving_source[2];
00051
00052 public:
00053
00058 Audio();
00059
00064 int initSound();
00065
00069 void exitOpenAL();
00070
00074 void killALData();
00075
00080 int getSoundId();
00081
00086 int getSoundCrashId();
00087 };
00088
00089
00090 class SoundEmitter : public osg::Node {
00091 public:
00092 SoundEmitter(ALuint source)
00093 : _source(source)
00094 {
00095 }
00096
00097 virtual Object* cloneType() const { return new SoundEmitter(_source); }
00098 virtual const char* className() const { return "SoundEmitter"; }
00099 virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const SoundEmitter*>(obj)!=NULL; }
00100
00101 virtual void accept(osg::NodeVisitor & nv) {
00102
00103 osg::Matrix m;
00104 osg::NodePath& fullNodePath = nv.getNodePath();
00105 m=osg::computeLocalToWorld(fullNodePath);
00106 osg::Vec3 front(m(0,0), m(1,0), m(2,0));
00107 osg::Vec3 pos(m(3,0), m(3,1), m(3,2));
00108 alSourcefv(_source, AL_DIRECTION, front._v);
00109 alSourcefv(_source, AL_POSITION, pos._v);
00110 nv.apply(*this);
00111 }
00112
00113 ALuint _source;
00114 };